{include file="public/layout" /}
<style>
    .layui-form-label{
        width: 150px;
    }
</style>
<body class="laytp-container">
<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <div class="layui-card-header">
            <i class="fa fa-pencil"></i> {$wallet[$money_type]}提现设置
        </div>
        <form class="layui-form" action="">
            <input type="hidden" name="money_type" value="{$money_type}" />
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-inline layui-input-wrap">
                    <input type="radio" name="status" value="0"  {if isset($config['status']) && $config['status']==0}checked='checked'{/if} title="关闭" lay-filter="switchStatus">
                    <input type="radio" name="status" value="1"  {if isset($config['status']) && $config['status']==1}checked='checked'{/if} title="开启" lay-filter="switchStatus">
                </div>
            </div>
            <div id="tx_div" {if isset($config['status']) && $config['status']==0}style="display: none;"{/if}>
                <div class="layui-form-item">
                    <label class="layui-form-label">手续费</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" name="fee" value="{$config['fee']}" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-text-em">%</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手续费来源</label>
                    <div class="layui-input-inline layui-input-wrap" style="width: 300px;">
                        <input type="radio" name="fee_type" value="0"  {if $config && $config['fee_type']==0}checked='checked'{/if} title="提现金额">
                        <input type="radio" name="fee_type" value="1"  {if $config && $config['fee_type']==1}checked='checked'{/if} title="额外货币">
                    </div>
                    <div class="layui-form-mid layui-text-em"></div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">到账比例</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" name="changebl" value="{$config['changebl']}" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-text-em">例：设置5，如果提现100，实际到账100x5=500</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">最大金额</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" name="max" value="{$config['max']}" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-text-em">单次提现最大金额，0代表不限制</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">最小金额</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" name="max" value="{$config['max']}" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-text-em">单次提现最小金额，0代表不限制</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">每月可提现日期</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" name="withdraw_date" value="{$config['withdraw_date']}" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-text-em">多个日期使用英文逗号分割，例：每月1、2号可提现，填写1,2</div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">确认</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(function(){
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var util = layui.util;

        // 自定义验证规则
        form.verify({
            pass: [
                /^[\S]{6,12}$/,
                '密码必须6到12位，且不能出现空格'
            ]
        });
        // 提交事件
        form.on('submit(demo1)', function(data){
            var index = layer.load();
            layer.close(index);

            var field = data.field; // 获取表单字段值
            $.ajax({
                type: "POST",
                url: "{:url('txset')}",
                data: field,
                success: function(res){
                    console.log(res);
                    if(res.status){
                        layer.msg('提交成功');
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
            return false; // 阻止默认 form 跳转
        });
        layui.form.on('radio(switchStatus)',function(data){
            console.log(data);
            if(data.value==1){
                $('#tx_div').show();
            }else{
                $('#tx_div').hide();
            }
        })
        // 日期
        laydate.render({
            elem: '#date'
        });


    });
</script>
</body>
</html>